﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;    // needed for Description Attributes/PropertyGrid
using System.Xml.Serialization;
using System.IO;

namespace Continuum.Classes
{
    public class ContinuumSettings
    {
        private string _ActiveUniverse = "";
        [Description("The last opened universe")]
        public string ActiveUniverse { get { return _ActiveUniverse; } set { _ActiveUniverse = value; } }

        #region Save/Load Universe

        public static ContinuumSettings LoadSettings(string Filename)
        {
            if (!File.Exists(Filename)) return null;

            ContinuumSettings newSettings;

            XmlSerializer s = new XmlSerializer(typeof(ContinuumSettings));
            TextReader r = new StreamReader(Filename);
            newSettings = (ContinuumSettings)s.Deserialize(r);
            r.Close();

            return newSettings;
        }

        public void SaveSettings(string Filename)
        {
            XmlSerializer s = new XmlSerializer(typeof(ContinuumSettings));
            TextWriter w = new StreamWriter(Filename);
            s.Serialize(w, this);
            w.Close();
        }

        #endregion

    }
}
